class Solution {
public:
    int halveArray(vector<int>& nums) {
        priority_queue<double> pq;
        double sum = 0;
        for (auto x : nums)
        {
            sum += x;
            pq.push(x);
        }
        sum /= 2.0;

        int ret = 0;
        while (sum > 0)
        {
            ret++;
            double tmp = pq.top() / 2;
            pq.pop();
            pq.push(tmp);
            sum -= tmp;
        }

        return ret;
    }
};